package me.zzp.skeleton;

import feign.Body;
import feign.Headers;
import feign.Param;
import feign.RequestLine;
import me.zzp.domain.Condition;
import me.zzp.domain.Page;
import me.zzp.domain.Pageable;
import me.zzp.model.User;

import java.util.List;

/**
 * @author zhangzepeng
 */
public interface UserSkeleton {

    @RequestLine("GET /users")
    List<User> all();

    @RequestLine("GET /users?condition={condition}")
    List<User> all(@Param("condition") Condition condition);

    @RequestLine("GET /users?pageable={pageable}")
    Page<User> all(@Param("pageable") Pageable pageable);

    @RequestLine("GET /users?condition={condition}&pageable={pageable}")
    Page<User> all(@Param("condition") Condition condition, @Param("pageable") Pageable pageable);

    @RequestLine("GET /users/{id}")
    User one(@Param("id") int id);

    @RequestLine("POST /users")
    @Headers("Content-Type: application/x-www-form-urlencoded")
    @Body("model={model}")
    User create(@Param("model") User user);

    @RequestLine("PATCH /users/{id}")
    @Headers("Content-Type: application/x-www-form-urlencoded")
    @Body("model={model}")
    int update(@Param("id") int id, @Param("model") User user);

    @RequestLine("PUT /users")
    @Headers("Content-Type: application/x-www-form-urlencoded")
    @Body("condition={condition}&model={model}")
    int update(@Param("user") User user, @Param("condition") Condition condition);

    @RequestLine("DELETE /users/{id}")
    int destroy(@Param("id") int id);

    @RequestLine("DELETE /users/{id}?version={version}")
    int destroy(@Param("id") int id, @Param("version") int version);

    @RequestLine("DELETE /users?condition={condition}")
    int destroy(@Param("condition") Condition condition);
}
